##############################################################
## MOD Title:   by lEx0
## MOD Author: lEx0 < http://torrentpier.ru >
## MOD Adapted: Nicolayka < http://t-torrents.org >
## MOD Version: 1.0
## :   ,    
## Installation Level: Easy
## Installation Time: 10 Minutes
## Files To Edit: config.php
##                index.php
##                viewonline.php
##				  includes/init_bb.php
##				  includes/page_header.php
##				  templates/default/index.tpl
##				  templates/default/viewonline.tpl
## Included Files:  none
## License: http://source.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## MOD History:
##    2011-01-01 - Version 1.0
##    	- initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL  ]---------------------------------
#

CREATE TABLE `bb_bots` (
  `bot_id` mediumint(8) unsigned NOT NULL auto_increment,
  `bot_name` varchar(255) character set utf8 NOT NULL,
  `bot_agent` varchar(255) character set utf8 collate utf8_esperanto_ci NOT NULL,
  `bb_visit` int(11) NOT NULL,
  PRIMARY KEY  (`bot_id`)
) ENGINE=MyISAM AUTO_INCREMENT=54 DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=54 ;

INSERT INTO `bb_bots` VALUES (1, 'AdsBot [Google]', 'AdsBot-Google', 0);
INSERT INTO `bb_bots` VALUES (2, 'Alexa [Bot]', 'ia_archiver', 0);
INSERT INTO `bb_bots` VALUES (3, 'Alta Vista [Bot]', 'Scooter/', 0);
INSERT INTO `bb_bots` VALUES (4, 'Ask Jeeves [Bot]', 'Ask Jeeves', 0);
INSERT INTO `bb_bots` VALUES (5, 'Baidu [Spider]', 'Baiduspider+(', 0);
INSERT INTO `bb_bots` VALUES (6, 'Exabot [Bot]', 'Exabot/', 0);
INSERT INTO `bb_bots` VALUES (7, 'FAST Enterprise [Crawler]', 'FAST Enterprise Crawler', 1297880788);
INSERT INTO `bb_bots` VALUES (8, 'FAST WebCrawler [Crawler]', 'FAST-WebCrawler/', 0);
INSERT INTO `bb_bots` VALUES (9, 'Francis [Bot]', 'http://www.neomo.de/', 0);
INSERT INTO `bb_bots` VALUES (10, 'Gigabot [Bot]', 'Gigabot/', 0);
INSERT INTO `bb_bots` VALUES (11, 'Google Adsense [Bot]', 'Mediapartners-Google', 0);
INSERT INTO `bb_bots` VALUES (12, 'Google Desktop', 'Google Desktop', 0);
INSERT INTO `bb_bots` VALUES (13, 'Google Feedfetcher', 'Feedfetcher-Google', 0);
INSERT INTO `bb_bots` VALUES (14, 'Google [Bot]', 'Googlebot', 1297925110);
INSERT INTO `bb_bots` VALUES (15, 'Heise IT-Markt [Crawler]', 'heise-IT-Markt-Crawler', 0);
INSERT INTO `bb_bots` VALUES (16, 'Heritrix [Crawler]', 'heritrix/1.', 0);
INSERT INTO `bb_bots` VALUES (17, 'IBM Research [Bot]', 'ibm.com/cs/crawler', 0);
INSERT INTO `bb_bots` VALUES (18, 'ICCrawler - ICjobs', 'ICCrawler - ICjobs', 0);
INSERT INTO `bb_bots` VALUES (19, 'ichiro [Crawler]', 'ichiro/', 0);
INSERT INTO `bb_bots` VALUES (20, 'Majestic-12 [Bot]', 'MJ12bot/', 0);
INSERT INTO `bb_bots` VALUES (21, 'Metager [Bot]', 'MetagerBot/', 0);
INSERT INTO `bb_bots` VALUES (22, 'MSN NewsBlogs', 'msnbot-NewsBlogs/', 0);
INSERT INTO `bb_bots` VALUES (23, 'MSN [Bot]', 'msnbot/', 0);
INSERT INTO `bb_bots` VALUES (24, 'MSNbot Media', 'msnbot-media/', 0);
INSERT INTO `bb_bots` VALUES (25, 'NG-Search [Bot]', 'NG-Search/', 0);
INSERT INTO `bb_bots` VALUES (26, 'Nutch [Bot]', 'http://lucene.apache.org/nutch/', 0);
INSERT INTO `bb_bots` VALUES (27, 'Nutch/CVS [Bot]', 'NutchCVS/', 0);
INSERT INTO `bb_bots` VALUES (28, 'OmniExplorer [Bot]', 'OmniExplorer_Bot/', 0);
INSERT INTO `bb_bots` VALUES (29, 'Online link [Validator]', 'online link validator', 0);
INSERT INTO `bb_bots` VALUES (30, 'psbot [Picsearch]', 'psbot/0', 0);
INSERT INTO `bb_bots` VALUES (31, 'Seekport [Bot]', 'Seekbot/', 0);
INSERT INTO `bb_bots` VALUES (32, 'Sensis [Crawler]', 'Sensis Web Crawler', 0);
INSERT INTO `bb_bots` VALUES (33, 'SEO Crawler', 'SEO search Crawler/', 0);
INSERT INTO `bb_bots` VALUES (34, 'Seoma [Crawler]', 'Seoma [SEO Crawler]', 0);
INSERT INTO `bb_bots` VALUES (35, 'SEOSearch [Crawler]', 'SEOsearch/', 0);
INSERT INTO `bb_bots` VALUES (36, 'Snappy [Bot]', 'Snappy/1.1 ( http://www.urltrends.com/ )', 0);
INSERT INTO `bb_bots` VALUES (37, 'Steeler [Crawler]', 'http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', 0);
INSERT INTO `bb_bots` VALUES (38, 'Synoo [Bot]', 'SynooBot/', 0);
INSERT INTO `bb_bots` VALUES (39, 'Telekom [Bot]', 'crawleradmin.t-info@telekom.de', 0);
INSERT INTO `bb_bots` VALUES (40, 'TurnitinBot [Bot]', 'TurnitinBot/', 0);
INSERT INTO `bb_bots` VALUES (41, 'Voyager [Bot]', 'voyager/1.0', 0);
INSERT INTO `bb_bots` VALUES (42, 'W3 [Sitesearch]', 'W3 SiteSearch Crawler', 0);
INSERT INTO `bb_bots` VALUES (43, 'W3C [Linkcheck]', 'W3C-checklink/', 0);
INSERT INTO `bb_bots` VALUES (44, 'W3C [Validator]', 'W3C_*Validator', 0);
INSERT INTO `bb_bots` VALUES (45, 'WiseNut [Bot]', 'http://www.WISEnutbot.com', 0);
INSERT INTO `bb_bots` VALUES (46, 'YaCy [Bot]', 'yacybot', 0);
INSERT INTO `bb_bots` VALUES (47, 'Yahoo MMCrawler [Bot]', 'Yahoo-MMCrawler/', 0);
INSERT INTO `bb_bots` VALUES (48, 'Yahoo Slurp [Bot]', 'Yahoo! DE Slurp', 0);
INSERT INTO `bb_bots` VALUES (49, 'Yahoo [Bot]', 'Yahoo! Slurp', 0);
INSERT INTO `bb_bots` VALUES (50, 'YahooSeeker [Bot]', 'YahooSeeker/', 0);
INSERT INTO `bb_bots` VALUES (51, ' ', 'Yandex/1.01.001 (compatible; Win16; I)', 0);
INSERT INTO `bb_bots` VALUES (52, ' [BOT]', 'Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)', 0);
INSERT INTO `bb_bots` VALUES (53, 'Bing [Bot]', 'bingbot/', 0);

#
#-----[  ]---------------------------------
#

config.php

#
#-----[    ]---------------------------------
#

//  by lEx0
$bb_cfg['search_bots'] = true;

#
#-----[  ]---------------------------------
#

index.php

#
#-----[  ]---------------------------------
#
// Statistics
if (!$stats = $datastore->get('stats'))
{
	$datastore->update('stats');
	$stats = $datastore->get('stats');
}

#
#-----[   ]---------------------------------
#

//  by lEx0
if($bb_cfg['search_bots'])
{
	if(!$bot_active = $bb_cache->get('active_bots'))
	{
		$bot_active = $db->fetch_rowset("SELECT bot_name  FROM ".BOTS_TABLE." WHERE bb_visit > ".(time()-300));
		$bb_cache->set('active_bots', $bot_active, 300);
	}
	$bcount = count($bot_active);
	if($bcount>0)
	{
		foreach ($bot_active AS $bkey=>$brow)
		{
			if($bkey == 0)
			{
				$brow['bot_name'] = '<span style="color:#000000;">,</span>&nbsp;'.$brow['bot_name'];
			}
			if($bcount-1 <> $bkey)
			{
				$brow['bot_name'] = $brow['bot_name'].'<span style="color:#000000;">,</span>&nbsp;';
			}
			$template->assign_block_vars('bots', $brow);
		}
	}
}

#
#-----[  ]---------------------------------
#

viewonline.php

#
#-----[  ]---------------------------------
#

print_page('viewonline.tpl');

#
#-----[   ]---------------------------------
#

//  by lEx0
if(!$bot_active = $bb_cache->get('active_bots'))
{
	$bot_active = $db->fetch_rowset("SELECT bot_name, bb_visit FROM ".BOTS_TABLE." WHERE bb_visit > ".(time()-300));
	$bb_cache->set('active_bots', $bot_active, 300);
}
$bcount = count($bot_active);
if($bcount>0)
{
	foreach ($bot_active AS $bkey=>$brow)
	{
		$brow['bb_visit'] = bb_date($brow['bb_visit']);
		$template->assign_block_vars('bots', $brow);
	}
}

#
#-----[  ]---------------------------------
#

includes/page_header.php

#
#-----[  ]---------------------------------
#

// Generate logged in/logged out status

#
#-----[   ]---------------------------------
#

/**
 * START   by lEx0
 *     
 */
if($bb_cfg['search_bots'])
{
	$template->assign_var('ENABLE_SEARCH_BOTS', true);
	$bots = array();
	if(!$bots = $bb_cache->get('bots'))
	{
		$bots = $db->fetch_rowset("SELECT * FROM " . BOTS_TABLE);
		$bb_cache->set('bots', $bots, 86400);
	}
	foreach ($bots AS $bot)
	{
		if(strstr($_SERVER['HTTP_USER_AGENT'], $bot['bot_agent']) <> FALSE)
		{
			$db->sql_query("UPDATE ".BOTS_TABLE." SET bb_visit=".time()." WHERE bot_id={$bot['bot_id']}");
			break;
		}
	}
}
/**
 * END   by lEx0
 */
 
#
#-----[  ]---------------------------------
#

includes/init_bb.php

#
#-----[  ]---------------------------------
#

define('GROUPS_TABLE',               'bb_groups');

#
#-----[   ]---------------------------------
#

define('BOTS_TABLE',				 'bb_bots'); //  by lEx0


#
#-----[  ]---------------------------------
#

templates/default/index.tpl

#
#-----[  ]---------------------------------
#

<div id="online_userlist" style="margin-top: 4px;">{LOGGED_IN_USER_LIST}</div>

#
#-----[   ]---------------------------------
#

<div id="online_userlist" style="margin-top: 4px;">{LOGGED_IN_USER_LIST}<!-- IF ENABLE_SEARCH_BOTS --><!-- BEGIN bots --><span class="colorBots"><b>{bots.bot_name}</b></span><!-- END bots --><!-- ENDIF --></div>

#
#-----[  ]---------------------------------
#

templates/default/viewonline.tpl

#
#-----[  ]---------------------------------
#

<!-- END guest_user_row -->

#
#-----[   ]---------------------------------
#

<!-- BEGIN bots -->
<tr class="rowq4">
 <td style="color:#000000;">{bots.bot_name}</td>
 <td class="tCenter">{bots.bb_visit}</td>
</tr>
<!-- END bots -->